package development;

import java.util.Hashtable;

import state.Alert;
import state.AlertMenu;
import state.GameForm;
import state.Key;
import state.component.TextField;
import state.util.Color;

public class FrmTestTouchTextField extends GameForm {
  private static GameForm singleton;
  
  public static GameForm instance() {
    if (singleton == null) {
      singleton = new FrmTestTouchTextField();
    }
    return singleton;
  }
  
  private TextField textField;

  public void init(Hashtable parameters) {
    manager.setBackGroundColor(Color.BLACK_CODE);
    textField = new TextField(manager, TextField.CONSTRAINT_ANY, Global.TEXT_FIELD_STYLE);
    textField.setFocused(true).setPosition(50, 50).setSize(150, 20);
  }
  
  public void keyReleased(int keyCode) {
    if (keyCode == Key.SOFT_RIGHT) {
      Global.nextState(FrmMenu.instance(), null);
      return;
    }
    
    if (keyCode == Key.FIRE) {
      AlertMenu.showAlert(this, null, new String[] {"Menu 1 rất dài aaaaa", "Menu 2 abc", "Menu 3"}, 99);
    }
    textField.keyReleased(keyCode);
  }
  
  public void alertEventPerform(int alertType, int eventType, int alertId) {
    if (alertType == Alert.CUSTOM_UI_TYPE) {
      Global.alert.showAlert(this, Alert.OK_TYPE, "Bạn đã chọn menu " + eventType);
    }
  }

  protected void destroy() {
  }
}
